<?php
/*	sslib@hazg.net	*/	

define('SSLIB_Utils', TRUE);


/**
 * Make query to default database
 *
 * @param string $query
 * @return Data
 */
function Q($query)
{
	$db = Sslib::DB();
	return $db->Query($query);
}
function tpf($arr, $file)
{
	if(!file_exists($file)) new Err(__T('file not found'));
	return tpl($arr, file_get_contents($file));
}
function tpl($arr, $string)
{
	return Template::Compile($arr, $string);
}
function qV($sql, $is_var = true){return Sql::QuoteValue($sql, $is_var);}
function qC($sql, $is_var = true){return Sql::QuoteColumn($sql, $is_var);}



function Allow($who, $message = false)
{
	if(!Permission::CheckUser($who))
	{
		if($message === false) $message = __T('access denided');
		print $message;			
		Page::Draw();
		exit;
	}
}
function __T($message)
{
	return Sslib::LocalizedMessage($message);
}
function RandomKey($len = 16, $simple = 0)
{
	static $arr = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
	$key='';
	$keylen = strlen($arr)-1-$simple;
	for($i = 0; $i != $len; $i++){$key .= $arr[rand(0, $keylen)];}
	return $key;
}

function Show($val)
{
	$var = print_r($val,true);
	return '<pre>'.highlight_string($var,true).'</pre>';
}

?>